﻿
using RTW.DAL;
using RTW.OA.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace RTW.OA.Areas.Personal.Servers
{
    public class WorkPlanServers
    {
	    private readonly IRepository<work_plan> work_planRepository;

        public WorkPlanServers()
        {
            work_planRepository = new DapperRepository<work_plan>();

        }

        public List<work_plan> GetData()
        {
            var datas = work_planRepository.GetAllEnumerable();

					  			return datas.ToList();
        }

        public work_plan GetModelById(string id)
        {
            return work_planRepository.GetById(id);
        }

		
        internal void Add(work_plan model)
        {
            work_planRepository.Insert(model);
        }

        internal void Update(work_plan model)
        {
            work_planRepository.Update(model);
        }

		internal void Del(string id)
        {
            work_planRepository.DeleteByIds(id);
        }

				      
        internal List<SelectListItem> GetTYPE()
        {
            List<SelectListItem> tables = new List<SelectListItem>();
            var dstable = work_planRepository.SqlWithParamsDynamic("select CODE_NO Value, concat(CODE_NO, '-----', CODE_NAME) Text  from[dbo].[sys_code] where PARENT_NO = 151");
            tables.Clear();

            foreach (var dr in dstable)
            {
                string Id = dr.Value.ToString();
                string Title = dr.Text.ToString().Trim();
                tables.Add(new SelectListItem { Value = Id, Text = Title });
            }

            return tables;
        }


                   	}
}